#!/usr/bin/python
import tornado.ioloop
import tornado.web


class basicRequestHandler(tornado.web.RequestHandler):
    def set_default_headers(self):
        self.set_header('Access-Control-Allow-Origin', 'micheliafigo.xyz')
        # self.set_header('Content-Type','text/plain; charset=UTF-8')
        # self.set_header('')

    def get(self):
        self.write("Served successfully.Get")

    def post(self):
        # self.set_header('Access-Control-Expose-Headers', 'Content-Type')
        self.write("Served successfully.Post")

    def options(self):
        self.set_header('Access-Control-Allow-Methods', 'PATCH')
        self.set_header('Access-Control-Allow-Headers', 'Content-Type,API-Key')
        self.finish()

    # def patch(self):
    #     self.write("Served successfully.Petch")


if __name__ == "__main__":
    app = tornado.web.Application([
        (r"/", basicRequestHandler)
    ])
    port = 8888
    app.listen(port)
    print("Application is ready and listening on port 8888")
    tornado.ioloop.IOLoop.current().start()
